package org.example.com.Handle;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import jakarta.activation.DataHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class NowDataHander implements MetaObjectHandler {

    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"ireDate",this::getNowDate,String.class);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "hireDate", this::getNowDate, String.class);
    }
   private String getNowDate(){
       SimpleDateFormat simp = new SimpleDateFormat("yyyy-MM-dd");
       Date date = new Date();
       return simp.format(date);
   }
}
